package com.bobo.controller;

import com.alibaba.fastjson.JSON;
import com.bobo.domain.Info;
import com.bobo.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class InfoController {
    @Autowired
    InfoService infoService;

    //跳转到增加页面
    @RequestMapping("toAdd")
    public String toAdd(){

        return "add";

    }


    //执行增加
    @ResponseBody
    @RequestMapping("add")
    public String toAdd(Info info){
        String[] domainNames = info.getDomainNames();
        info.setDomainName(JSON.toJSONString(domainNames));
        return infoService.insert(info)>0?"success":"fail";
    }
}
